package org.example.util;

import cn.hutool.core.util.StrUtil;
import lombok.Getter;

import java.util.Arrays;

@Getter
public enum DisposalMethodEnum {
    EXCHANGE("Exchange", "换货"),
    RETURN("Return", "退货"),

    ;

    private final String code;

    private final String desc;

    DisposalMethodEnum(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public static String getCodeByDesc(String desc) {
        if (StrUtil.isNotBlank(desc)) {
            return Arrays.stream(values()).filter(item -> item.getDesc().equals(desc)).findFirst().get().getCode();
        }
        return null;
    }

    public static String getDescByCode(String code) {
        if (StrUtil.isNotBlank(code)) {
            return Arrays.stream(values()).filter(item -> item.getCode().equals(code)).findFirst().get().getDesc();
        }
        return null;
    }
}